using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using Afrs.Draco.Prms.Client.Proxy;
using Afrs.Prms.DataObject;

namespace 
{
  /// <summary>
  /// Categories Test Class
  /// </summary>
  [TestClass]
  public class TestCategories
  {
    #region Class Variables
    private CdoPrms<DOCategories>		m_Categories;
    private CdoPrmsList<DOCategories>	m_AllCategories;
    #endregion

    #region Class Constructors & Destructors
    /// <summary>
    /// Constructs the test
    /// </summary>
    public TestCategories()
    {
      // Create the data objects
      this.m_Categories	= new CdoPrms<DOCategories>();
      this.m_AllCategories	= new CdoPrmsList<DOCategories>();
    }
    #endregion

    #region Class Methods
    /// <summary>
    /// Retrieves all Categories data objects
    /// </summary>
    [TestMethod]
    public void CategoriesRetrieveAll()
    {
      // Set up the data object for list retrieval
      this.m_AllCategories.DataObject = new DOCategories();
      this.m_AllCategories.ListAction = AfrsDOListAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_AllCategories.PerformAction())
      {
        // Assert the errors
        if (this.m_AllCategories.Errors.Count > 0) { Assert.Fail(this.m_AllCategories.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Create a new Categories
    /// </summary>
    [TestMethod]
    public void CategoriesCreate()
    {
      // Set up the data object for creation
      this.m_Categories.DataObject.DivisionName = "Test DivisionName";
      this.m_Categories.DataObject.DepartmentName = "Test DepartmentName";
      this.m_Categories.DataObject.Action = AfrsDataObjectAction.Create;

      // Perform the action and determine the success
      if (!this.m_Categories.PerformAction())
      {
        // Assert the errors
        if (this.m_Categories.Errors.Count > 0) { Assert.Fail(this.m_Categories.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }

    /// <summary>
    /// Retrieves a specific Categories
    /// </summary>
    [TestMethod]
    public void CategoriesRetrieve()
    {
      // Determine whether the data object needs to be specified
      if (this.m_Categories.DataObject.Id == 0)
      {
        // Specify the data object to retrieve
        this.m_Categories.DataObject.CategoryName = "Test CategoryName";
      }

      // Set up the data object action for retrieval
      this.m_Categories.DataObject.Action = AfrsDataObjectAction.Retrieve;

      // Perform the action and determine the success
      if (!this.m_Categories.PerformAction())
      {
        // Assert the errors
        if (this.m_Categories.Errors.Count > 0) { Assert.Fail(this.m_Categories.Errors[0].Message); }
        else { Assert.Fail("Unknown error occurred"); }
      }

      // Return to calling method
      return;
    }
    #endregion
  }
}
